/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.domain.items;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Ripper
 */
public class Equipment extends Item 
{
    private EquipmentSetPiece partOfSet = EquipmentSetPiece.NONE;
    
    private int armorValue;
    private int magicArmorValue;
    
    private List<ItemAttribute> equipmentAttributes;
    
    public Equipment(String itemName, int itemCost, int looktype, int armVal, int magicArmVal, List<ItemAttribute> attributes)
    {
        super(itemName, itemCost, looktype);
        
        setArmorValue(armVal);
        setMagicArmorValue(magicArmVal);
        setEquipmentAttributes(attributes);
    }
    public Equipment(String itemName, int itemCost, int looktype, int armVal, int magicArmVal, List<ItemAttribute> attributes,
            EquipmentSetPiece partOfASet)
    {
        super(itemName, itemCost, looktype);
        
        setArmorValue(armVal);
        setMagicArmorValue(magicArmVal);
        setEquipmentAttributes(attributes);
        
        setPartOfSet(partOfASet);
    }

    public EquipmentSetPiece getPartOfSet() { return partOfSet; }
    public final void setPartOfSet(EquipmentSetPiece partOfSet) { this.partOfSet = partOfSet; }
    public int getArmorValue() { return armorValue; }
    public final void setArmorValue(int armorValue) { this.armorValue = armorValue; }
    public int getMagicArmorValue() { return magicArmorValue; }
    public final void setMagicArmorValue(int magicArmorValue) { this.magicArmorValue = magicArmorValue; }

    public List<ItemAttribute> getEquipmentAttributes() {
        return equipmentAttributes;
    }
    public final void setEquipmentAttributes(List<ItemAttribute> equipmentAttributes) {
        this.equipmentAttributes = equipmentAttributes;
    }
    public void addEquipmentAttribute(ItemAttribute ia)
    {
        equipmentAttributes.add(ia);
    }
    @Override
    public Item copyItem()
    {
        List<ItemAttribute> attribs = new ArrayList<ItemAttribute>();
        for(ItemAttribute ia: getEquipmentAttributes())
        {
            attribs.add(new ItemAttribute(ia.getAttribute(), ia.getAttributeValue()));
        }
        
        Equipment i = new Equipment(getItemName(), getItemCost(), getLooktype(), getArmorValue(), getMagicArmorValue(), attribs);
        return i;
    }
    @Override
    public String getItemType()
    {
        return "equipment";
    }
    @Override
    public String getItemAttributes()
    {
        String data = super.getItemAttributes();
        
        if(partOfSet != EquipmentSetPiece.NONE)
        {
            data += ", Part of the " + partOfSet + " set";
        }
        data += ", Armor: " + getArmorValue() + ", ";
        data += "Magic Armor: " + getMagicArmorValue() + ", ";
        
        for(ItemAttribute ia: equipmentAttributes)
        {
            data += "" + ia.toString() + ", ";
        }
        
        data = data.substring(0, data.length()-2);
        
        return data;
    }
    
}
